<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
	<head>
		<jsp:include page="/common.jsp"/>
	</head>
	
	<body topmargin="0" bottommargin="0" marginheight="100%" marginwidth="100%">
		<div id="treebox" style="width:100%; height:100%;border :1px solid Silver;"></div>
		<script>
			var tree=new dhtmlXTreeObject("treebox","100%","100%",0);
			tree.setImagePath("${pageContext.request.contextPath }/resource/dhtmlx/imgs/");
//			添加点击事件
			tree.setOnClickHandler(onNodeSelect);
			//是否需要checkbox
			if ("${roleFormBean.isCheckBox}" == "1"){
				tree.enableCheckBoxes(1);//带 checkBox 的 tree
				tree.enableThreeStateCheckboxes(true);//级联选择
			}
			tree.loadXMLString('${roleFormBean.treeStr}');
			
			
			function onNodeSelect(id){
				treeNodeSelect(id);
			}
			</script>
			
			<script>
//			扩展此方法
			function treeNodeSelect(id){
				if (window.dialogArguments){
					//弹出式
					if ("${roleFormBean.jsCallBackFunction}" == ""){
						if(window.dialogArguments.popCallback(id, tree.getItemText(id)))
							window.close();
					}else{
						if(window.dialogArguments.eval('${roleFormBean.jsCallBackFunction}("'+id+'", "'+tree.getItemText(id)+'")'))
							window.close();
					}
				}else if (parent){
					parent.treeSelect(id);
				}
			}
			
		</script>
	</body>
</html>